package signals

import (
	"os"
	"os/signal"
	"syscall"
)

func Shutdown(stop func(grace bool)) {
	//创建监听退出chan
	sig := make(chan os.Signal, 2)
	//监听指定信号
	signal.Notify(
		sig,
		shutdownSignals...,
	)
	go func() {
		// Block until a signal is received.
		s := <-sig
		go stop(s != syscall.SIGQUIT)
		<-sig
		os.Exit(128 + int(s.(syscall.Signal)))
	}()
}
